package net.beyondts.mplug;

import org.apache.commons.lang3.reflect.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired;

import java.lang.reflect.InvocationTargetException;

/**
 * If you want to invoke a Spring-AOP proxied bean's method inside the bean, proxy will never effect, so use this class as the base class of the one has this usage.
 * You can alse use BeanFactory.getBean().method() to archive the same purpose.
 *
 * @author blazecrystal
 */
public class Self {
    @Autowired
    protected Self self;

    protected Object invokeSelf(String methodName, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        return MethodUtils.invokeMethod(self, true, methodName, args);
    }
}
